<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <!-- layui js-->
    <script type="text/javascript" src="/static/layui/layui.js"></script>
</head>
<body>
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo layui-hide-xs layui-bg-black">恋 爱 广 场</div>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                    <a href="javascript:;">
                        <i class="layui-icon layui-icon-friends"></i>
                        潘毅
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="">个人主页</a></dd>
                        <dd><a href="">设置</a></dd>
                        <dd><a href="">登出</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                    <a href="javascript:;">
                        <i class="layui-icon layui-icon-more-vertical"></i>
                    </a>
                </li>
            </ul>
        </div>
        <div class="layui-side layui-bg-black">
            <ul class="layui-nav layui-nav-tree">
                <li class="layui-nav-item" style="padding-left: 30px"><a href="index"><i class="layui-icon layui-icon-heart-fill"></i>  广场</a></li>
                <li class="layui-nav-item" style="padding-left: 30px"><a href=""><i class="layui-icon layui-icon-friends"></i>  个人</a></li>
                <li class="layui-nav-item" style="padding-left: 30px ; background: #5FB878"><a href="write"><i class="layui-icon layui-icon-release"></i>  发布</a></li>

            </ul>
        </div>
        <div class="layui-body">
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
                <legend>恩爱秀起来</legend>
            </fieldset>
            <textarea id="editor" style="display: none;"></textarea>
            <button type="button" class="layui-btn" lay-active="publish">开始秀恩爱</button>
        </div>
        <div class="layui-footer">
            copyright@panyi 2021
        </div>
    </div>
    <script>
        layui.use(['layedit','util','layer'],function(){
            var layedit = layui.layedit
            ,$ = layui.jquery
            ,util = layui.util
            ,layer = layui.layer;
            layedit.set({
                uploadImage: {
                    url: '/upload/img' //接口url
                    ,type: 'post'//默认post
                }
            });
            var noteEditor = layedit.build('editor'); //建立编辑器
            util.event('lay-active',{
                publish: function(){
                    var msg = layedit.getContent(noteEditor);
                    console.log(msg)
                    $.ajax({
                        url:"/upload",
                        type:"post",
                        data:JSON.stringify({
                                author:"风继续吹",
                                authorId:"1132",
                                noteText:msg
                            }),
                        contentType: "application/json;charset=UTF-8",
                        dataType:"text",
                        success:function (data) {
                            layer.msg(data)
                        },
                        error:function (data){
                            layer.msg(data)
                        }
                    })
                }
            });
        });
    </script>
</body>
</html>